import api from '../../js/api';
import Dialog from '@vant/weapp/dialog/dialog';
Page({


    data: {
        wname: "",
        menu_arr: [],
        menus: {}
    },

    onShow() {
        let token = wx.getStorageSync('token')
        api.getWname(token).then((r) => {
            //console.log(r.data[0]);
            this.setData({ "wname": r.data[0].wname })
            wx.setStorageSync('user', r.data[0])
        })


        /**
         * 00010	扫码入库
            00020	入库查询
            00030	出仓通知单
            00040	配载拣货
            00050	移仓出仓单
            00060	移仓入仓单
            00070	盘点单
            00080	仓库状态

         */
        api.getPdaMenu(token).then(r => {
            let menusStr = r.data[0]

            if (menusStr.pdamenus) {
                let menu_arr = menusStr.pdamenus.split(',')

                let menus = {}
                menus.m00010 = menu_arr.includes("00010")
                menus.m00020 = menu_arr.includes("00020")
                menus.m00030 = menu_arr.includes("00030")
                menus.m00040 = menu_arr.includes("00040")
                menus.m00050 = menu_arr.includes("00050")
                menus.m00060 = menu_arr.includes("00060")
                menus.m00070 = menu_arr.includes("00070")
                menus.m00080 = menu_arr.includes("00080")
                this.setData({ menu_arr, menus })
            }
        })
    },

    onLoad(options) {
        wx.hideHomeButton({
            success: function(a) {}
        });




    },

    logout() {

        Dialog.confirm({
                title: '提示',
                message: '确认退出？',
            }).then(() => {
                wx.setStorageSync('token', "")
                wx.redirectTo({
                    url: "/pages/Login/Login"
                })
            })
            .catch(() => {

            });
    },
    test() {
        wx.showToast({
            title: '此功能正在更新',
        })
    }

})